<!-- 菜品列表 -->
<div class="search">
  <!-- <nz-select  style="width:300px;" [(ngModel)]="mid" nzAllowClear nzPlaceHolder="商户名称" (ngModelChange)="searchData()">
    <nz-option *ngFor="let item of merchantlist" [nzValue]="item.key" [nzLabel]="item.value"></nz-option>
  </nz-select> -->
  <nz-select style="width:100px;" [(ngModel)]="status" nzAllowClear nzPlaceHolder="菜品状态" (ngModelChange)="searchData()">
    <nz-option *ngFor="let item of statuslist" [nzValue]="item.key" [nzLabel]="item.value"></nz-option>
  </nz-select>
  <nz-input-group nzSuffixIcon="anticon anticon-search" style="width:30%;margin-left:1rem;">
    <input type="text" nz-input placeholder="输入菜品名称查询" [(ngModel)]="name" (keyup.enter)="searchData()">
  </nz-input-group>
  <a (click)="searchData()">查询</a>
  <a (click)="add()">添加</a>
</div>

<nz-table #ajaxTable nzShowSizeChanger [nzFrontPagination]="false" [nzData]="dataSet" [nzLoading]="loading" [nzTotal]="total"
  [nzShowTotal]="totalTemplate" [(nzPageIndex)]="pageIndex" [(nzPageSize)]="pageSize" (nzPageIndexChange)="searchData()"
  (nzPageSizeChange)="searchData(true)" [nzScroll]="{ x:'1200px',y: '400px' }">
  <thead>
    <tr>
      <th nzWidth="60px" nzLeft="0px">序号</th>
      <th nzWidth="100px">商户名称</th>
      <th nzWidth="100px">菜品名称</th>
      <th nzWidth="100px">描述</th>
      <th nzWidth="100px">类型</th>
      <th nzWidth="100px">单价(元)</th>
      <th nzWidth="60px">序号</th>
      <th nzWidth="100px">备注</th>
      <th nzWidth="140px">更新时间</th>
      <th nzWidth="80px">状态</th>
      <th nzWidth="100px" nzRight="0px">操作</th>
    </tr>
  </thead>
  <tbody>
    <tr *ngFor="let data of ajaxTable.data;index as i">
      <td nzLeft="0px">{{i+1}}</td>
      <td>{{data.mername}}</td>
      <td>{{data.name}}</td>
      <td>{{data.lable}}</td>
      <td>{{data.type}}</td>
      <td>{{data.price}}</td>
      <td>{{data.order}}</td>
      <td>{{data.remarks}}</td>
      <td>{{data.updateTime}}</td>
      <td>{{data.status}}</td>
      <td nzRight="0px">
        <a (click)="edit(data._id)">编辑</a>
        <a *ngIf="data.status=='售卖中'" (click)="lock(data._id)">下架</a>
        <a *ngIf="data.status!='售卖中'" (click)="open(data._id)">上架</a>
      </td>
    </tr>
  </tbody>
</nz-table>

<ng-template #totalTemplate let-total>
  共 {{total}} 条
</ng-template>
<nz-modal [(nzVisible)]="isVisible" nzTitle="菜品信息" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()" nzWrapClassName="vertical-center-modal"
  [nzMaskClosable]="false" nzWidth="800" >
  <div style="margin-bottom: 16px;" class="scrollbar">
    <nz-input-group nzAddOnBefore="菜品名称">
      <input type="text" nz-input [(ngModel)]="doc.name">
    </nz-input-group>
    <nz-input-group nzAddOnBefore="菜品描述">
      <input type="text" nz-input [(ngModel)]="doc.lable">
    </nz-input-group>
    <nz-input-group nzAddOnBefore="菜品价格">
      <input type="text" nz-input [(ngModel)]="doc.price">
    </nz-input-group>
    <nz-input-group nzAddOnBefore="菜品类型">
      <nz-select nzMode="tags" style="width: 100%;" nzPlaceHolder="请选择类型" [(ngModel)]="doc.type">
        <nz-option *ngFor="let item of typeItems" [nzLabel]="item.value" [nzValue]="item.key">
        </nz-option>
      </nz-select>
    </nz-input-group>
    <li><span>菜品图片：</span>
        <nz-upload class="avatar-uploader" [nzAction]="action" nzName="file" nzListType="picture-card" title="点击上传图片"
          [nzShowUploadList]="false" [nzBeforeUpload]="beforeUpload" (nzChange)="handleChange($event,'firstimg')">
          <ng-container *ngIf="!doc.img">
            <i nz-icon type="plus"></i>
            <div class="ant-upload-text">上传图片</div>
          </ng-container>
          <img *ngIf="doc.img" [src]="doc.img" class="avatar">
        </nz-upload>
    </li>
    <nz-input-group nzAddOnBefore="顺序号">
      <input type="text" nz-input [(ngModel)]="doc.order">
    </nz-input-group>
  </div>